package com.xinruke.hostels.systemmanage.controller;

import com.xinruke.hostels.common.controller.BaseController;
import com.xinruke.hostels.common.vo.ResultVO;
import com.xinruke.hostels.common.vo.query.RowsDataVO;
import com.xinruke.hostels.system.manage.interfaces.dto.*;
import com.xinruke.hostels.systemmanage.service.MeetingTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @ClassName MeetingTypeController
 * @date：2019/6/24
 * @author GuoZheng
 * @version: 1.0
 * @description：会议室类型Controller
 */
@RestController
@RequestMapping("/meeting-type/")
@Api(tags = "会场类型")
@Slf4j
public class MeetingTypeController extends BaseController {

    @Autowired
    private MeetingTypeService meetingTypeService;

    @PostMapping("/add")
    @ApiOperation("添加")
    public ResultVO add(@Valid @RequestBody MeetingTypeAddDTO addQueryDTO) {
        return meetingTypeService.add(addQueryDTO);
    }

    @PostMapping("/modify")
    @ApiOperation("修改")
    public ResultVO modify(@Valid @RequestBody MeetingTypeModifyDTO modifyQueryDTO) {
        return meetingTypeService.modify(modifyQueryDTO);
    }

    @PostMapping("/del")
    @ApiOperation("删除")
    public ResultVO delete(@Valid @RequestBody MeetingTypeDelDTO delQueryDTO) {
        return meetingTypeService.delete(delQueryDTO);
    }

    /**
     *通过酒店id查询旗下所有会议室
     * @return
     */
    @PostMapping("/hotel")
    @ApiOperation(value = "查询酒店下的所有会议类别")
    public ResultVO<RowsDataVO<MeetingTypeQueryResultDTO>> getPmsMeetingTypeList(@Valid @RequestBody MeetingTypeQueryDTO underHotelQueryDTO) {
        ResultVO<RowsDataVO<MeetingTypeQueryResultDTO>> resultVO = ResultVO.fail();
        RowsDataVO<MeetingTypeQueryResultDTO> dataVO = meetingTypeService.getPmsMeetingTypeList(underHotelQueryDTO);
        resultVO.setCode(ResultVO.SUCCESS);
        resultVO.setMessage("操作成功");
        resultVO.setData(dataVO);
        return resultVO;
    }

    /**
     *通过酒店id查询旗下所有会议室
     * @return
     */
    @PostMapping("/reservation/hotel")
    @ApiOperation(value = "查询预订酒店下的所有会议类别")
    public ResultVO<RowsDataVO<ReservationMeetingTypeResultDTO>> getReservationMeetingTypeList(@Valid @RequestBody ReservationMeetingTypeQueryDTO queryDTO) {
        return  meetingTypeService.getReservationMeetingTypeList(queryDTO);

    }

    /**
     * 通过id查询详情
     * @return 会场类型详情
     */
    @PostMapping("/detail")
    @ApiOperation(value = "会议类别详情")
    public ResultVO<MeetingTypeDetailQueryResultDTO> getDetail(@Valid @RequestBody MeetingTypeDetailQueryDTO detailQueryDTO) {

        MeetingTypeDetailQueryResultDTO detail = meetingTypeService.getDetail(detailQueryDTO);
        if (null == detail) {
            return ResultVO.fail("没有此会场类型");
        }
        ResultVO<MeetingTypeDetailQueryResultDTO> resultVO = ResultVO.success();
        resultVO.setMessage("操作成功");
        resultVO.setData(detail);
        return resultVO;
    }

}
